import Vue from 'vue'

import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        msgListHappy: [],
        msgListCheat: []
    },
    mutations: {
        //这里是set方法
        setMsgListHappy(state, message) {
            if(state.msgListHappy == undefined){
                state.msgListHappy = message;
            }
            else state.msgListHappy.push(message);
            // console.log(state.msgList)
        },
        setMsgListCheat(state, message) {
            if(state.msgListCheat == undefined){
                state.msgListCheat = message;
            }
            else state.msgListCheat.push(message);
            // console.log(state.msgList)
        }

    },

    getters: {

        //get方法

        getMsgListHappy: state => state.msgListHappy

    },

    actions: {

        //这个部分我暂时用不上

    },

    modules: {

        //这里是我自己理解的是为了给全局变量分组，所以需要写提前声明其他store文件，然后引入这里

    }

})